/*
 * @Author: Zhong admin@51y.cc
 * @Description: 基础数据
 * @FilePath: \tenement-admin\src\store\modules\base.js
 * @LastEditTime: 2024-10-16 20:58:52
 * @LastEditors: Zhong
 */
import { getCommunityPage } from "@/api/realEstateManage";
import { getToken } from "@/utils/auth";
const useBaseStore = defineStore("base", {
  state: () => ({
    loadError: false,
    communityList: [],
  }),
  actions: {
    getCommunityList() {
      if (getToken()) {
        getCommunityPage({
          pageNo: 1,
          pageSize: 9999,
        })
          .then(({ data }) => {
            this.communityList = data.records;
            this.loadError = false;
          })
          .catch(() => {
            this.communityList = [];
            this.loadError = true;
          });
      }
    },
  },
});

export default useBaseStore;
